package com.jd.service.impl;

import com.jd.entity.Menu;
import com.jd.mapper.MenuMapper;
import com.jd.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jd.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 系统菜单 服务实现类
 * </p>
 *
 * @author wangshuping
 * @since 2021-11-21
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    @Autowired
    private RoleService roleService;

    @Override
    public List<Menu> getMenuListByUserId(Long userId) {
        // 1 roleService->>拥有所有的菜单
        if(roleService.isSuperAdmin(userId)){
            return list() ; // 查询所有
        }
        // 2 如果该用户不是超级管理员->>查询角色->查询菜单
        return this.baseMapper.getMenuListByUserId(userId);
    }
}
